package com.example.myapp.activities.show_bills_by_months;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.myapp.R;
import com.example.myapp.adapters.StableArrayAdapter;
import com.example.myapp.bill.Bill;

import java.util.List;

/**
 * Autor: Daniel Michalski
 * Data: 17.05.13
 */

public class StabledArrayAdapter extends StableArrayAdapter {
    /**
     * Konstruktor klasy SpecialAdapter
     *
     * @param context        obecny kontekst
     * @param listaRachunkow listaZRachunkami
     */
    public StabledArrayAdapter(Context context, List<Bill> listaRachunkow) {
        super(context, listaRachunkow);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.row, null);
            holder = new ViewHolder();
            holder.text = (TextView) convertView.findViewById(R.id.headline);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.text.setText(data.get(position).getName() + " - " + data.get(position).getAmount() + " zł");
        convertView.setBackgroundColor(Color.BLACK);

        if (selected.get(position)) {
            convertView.setBackgroundColor(Color.rgb(0, 153, 204));
        }
        notifyDataSetChanged();


        return convertView;
    }
}
